package com.example.studentregistration.AppController;

import com.example.studentregistration.pojo.StudentApp;
import com.example.studentregistration.service.StudentAppService;
import com.example.studentregistration.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/appApi/student")
public class StudentAppController {

    @Autowired
    private StudentAppService studentAppService;

    /* 信息提交：POST /api/student/submit */
    @PostMapping("/submit")
    public Result<?> submit(@RequestBody StudentApp dto) {
        return studentAppService.submitStudentInfo(dto);
    }

    /* 信息回显：GET /api/student/info?studentNo=12345 */
    @GetMapping("/info")
    public Result<StudentApp> getInfo(@RequestParam String studentNo) {
        return studentAppService.getStudentInfoByNo(studentNo);
    }
    /* 登录：POST /api/student/login */
    @PostMapping("/login")
    public Result<StudentApp> login(@RequestBody Map<String,String> map) {
        System.out.println(map.get("phone")+"ksdlfsf");
        return studentAppService.login(map.get("phone"), map.get("password"));
    }



}
